using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using UniversalAdmin.Application.Commands;
using UniversalAdmin.Application.Dto;
using UniversalAdmin.Application.Services;
using UniversalAdmin.Api.Filters;

[ApiController]
[Route("api/users/{userId}/roles")]
[Authorize]
public class UserRoleMappingsController : ControllerBase
{
    private readonly IAppUserRoleMappingServices _service;
    public UserRoleMappingsController(IAppUserRoleMappingServices service) { _service = service; }

    // [HttpPost] 分配角色方法已删除，避免路由冲突

    // [HttpGet] 方法已删除，避免路由冲突

    [HttpDelete("{roleId}")]
    [RequirePermission("user.manage")] // 需要管理用户权限
    public async Task<ApiResult> RemoveUserRole(Guid userId, Guid roleId)
    {
        return await _service.RemoveUserRoleAsync(userId, roleId);
    }
} 